package com.example.userservice.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.common.domain.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;


@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("SELECT * FROM users WHERE id = #{id} AND password = #{password}")
    User selectByUsernameAndPassword(@Param("id") String id, @Param("password") String password);

    @Select("SELECT * FROM users WHERE phone = #{phone}")
    User getPhone(@Param("phone") String phone);


    // 通过用户ID更新头像URL
    @Update("UPDATE users SET img_url = #{imgUrl} WHERE id = #{id}")
    int updateAvatarUrl(String id, String imgUrl);

}
